<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ajout produit chere</title>

<!------------------------------ajax---------------------------->
<!-- <script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
    <script type="text/javascript"  src="http://malsup.github.com/jquery.form.js"></script> -->
	
<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form validation ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.validate.js');?>" ></script>
<!---------------------for form mask input ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.mask.min.js');?>" ></script>


</head>
<body>
<?php
include_once('header.php');

?>

<?php
echo form_open_multipart( base_url('convention_annex_crt/valider_ajout_prod_chere_annex').'/'.$id_convention_annex.'/'.$id_fournisseur ); 
?>

<form id="ajout_form" class="pure-form pure-form-stacked" method="POST" action="<?php echo base_url('bc_ctr/valider_ajout_prod_chere_annex').'/'.$id_convention_annex.'/'.$id_fournisseur ;?>">
    <fieldset>
        <legend style="background-color: red; font-size: 150%">سعر هذا المنتج يفوق السعر المعتاد و الذي يقدر ب : <?php echo $prix_original ;?></legend>

        <div class="pure-g">
          
            <div class="pure-u-1 pure-u-md-1-3 ">
                <label for="numero"> المنتج </label>
				<input class="ltr" id="dessignation" name="dessignation" type="text" value="<?php echo($dessignation);?> ">
                
            </div>
			
            <div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">
                <label for="article">السعر </label>
                <input  class="ltr" id="prix" name="prix" type="text" value="<?php echo($prix);?>">
            </div>

            <div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">
                <label for="numero"> الكمية </label>
				<input class="ltr" id="quantite" name="quantite" type="text" value="<?php echo($quantite);?>">
                
            </div>
	
		
        </div>

      <input type="submit" id="ajouter" value="اضافة"  class="pure-button pure-button-primary" />
    <a href="<?php echo base_url("/convention_crt/")?>" class="pure-button pure-button-primary">الغاء</a>
    </fieldset>
</form>

			

</body>

<script>
$(document).ready(function() {


var liste_prod = <?php echo json_encode($liste_des_produit); ?>;

$( "#dessignation" ).autocomplete({source: liste_prod});

});

$('#ajouter').click(function() {
  if($("[class^=error]").is(":visible")){
    alert('منالك حقل / حقول إدخال غير مطابقة !');
    return false;
  } else {
  	
	 base_url('bc_ctr/valider_ajout_prod($id_bc)') 
  //	$('#ajout_form').submit();
    return false;
  }
});


$('#prix').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    //var characterReg = /^([a-zA-Z0-9]{7,16})$/;
    var characterReg = /^([0-9]+([,]{0,1}[0-9]+){0,1})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" flag="required" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});

$('#quantite').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    //var characterReg = /^([a-zA-Z0-9]{7,16})$/;
    var characterReg = /^([0-9]+)$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" flag="required" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});


</script>

</html>